home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Palm-Software / Emulator 3.2 / Perl / EmFunctions.pm next >
Encoding:
Text File  |  2001-06-03  |  29.0 KB  |  975 lines

  1. ########################################################################
  2. #
  3. #    File:            EmFunctions.pm
  4. #
  5. #    Purpose:        Perl wrappers for Palm OS functions
  6. #
  7. #    Description:    This file contains Perl equivalents of Palm OS
  8. #                    functions like DmNumDatabases, FrmGetActiveForm,
  9. #                    etc.  Currently, the functions here are generated
  10. #                    by hand, and so only a small subset of Palm OS
  11. #                    functions are wrapped.  In the future, this file
  12. #                    (or files) may be automatically generated by
  13. #                    a script that converts the SDK headers.
  14. #
  15. #                    In general, functions follow the calling
  16. #                    conventions in the SDK headers.  However, there
  17. #                    are exceptions.  See the comments before each
  18. #                    subroutine for details.
  19. #
  20. ########################################################################
  21.  
  22. package EmFunctions;
  23.  
  24. use Exporter ();
  25. @ISA = qw(Exporter);
  26.  
  27. @EXPORT = qw(
  28.     CtlGetLabel
  29.  
  30.     DmNumDatabases DmFindDatabase DmDatabaseInfo
  31.  
  32.     EvtEnqueuePenPoint EvtEnqueueKey
  33.  
  34.     FrmGetActiveForm FrmGetLabel FrmGetNumberOfObjects FrmGetObjectBounds
  35.     FrmGetObjectId FrmGetObjectIndex FrmGetObjectPtr FrmGetObjectType FrmGetTitle
  36.  
  37.     FtrGet
  38.  
  39.     HostGetHostVersion
  40.     HostGremlinNew
  41.     HostSessionCreate HostSessionOpen HostSessionClose HostSessionQuit
  42.     HostSignalWait HostSignalResume
  43.  
  44.     HwrDisplayAttributes
  45.  
  46.     MemChunkFree MemPtrFree MemPtrNew MemPtrSetOwner
  47.  
  48.     SysUIAppSwitch
  49.  
  50.     WinDisplayToWindowPt WinWindowToDisplayPt
  51.  
  52.     frmFieldObj frmControlObj frmListObj frmTableObj frmBitmapObj frmLineObj
  53.     frmFrameObj frmRectangleObj frmLabelObj frmTitleObj frmPopupObj
  54.     frmGraffitiStateObj frmGadgetObj frmScrollBarObj
  55.  
  56.     hwrDispType            hwrDispRev            hwrDispVers            hwrDispAllDepths    hwrDispMaxDepth
  57.     hwrDispBootDepth    hwrDispMaxGrays        hwrDispHorizontal    hwrDispVertical        hwrDispVRAMBaseAddr
  58.     hwrDispVRAMSize        hwrDispColor        hwrDispName            hwrDispBaseAddr        hwrDispDepth
  59.     hwrDispWidth        hwrDispHeight        hwrDispRowBytes        hwrDispBacklight    hwrDispBrightness
  60.     hwrDispContrast        hwrDispDbgIndicator    hwrDispEndAddr        hwrDispBufferMask    hwrDispResolutionX
  61.     hwrDispResolutionY    hwrDispMemAccessOK
  62. );
  63.  
  64. use EmRPC;
  65. use EmSysTraps;
  66.  
  67. $slkSocket = EmRPC::slkSocketPoserRPC;
  68. #$slkSocket = EmRPC::slkSocketDebugger;
  69. $slkPktType = EmRPC::slkPktTypeSystem;
  70.  
  71. use constant frmFieldObj            => 0;
  72. use constant frmControlObj            => 1;
  73. use constant frmListObj                => 2;
  74. use constant frmTableObj            => 3;
  75. use constant frmBitmapObj            => 4;
  76. use constant frmLineObj                => 5;
  77. use constant frmFrameObj            => 6;
  78. use constant frmRectangleObj        => 7;
  79. use constant frmLabelObj            => 8;
  80. use constant frmTitleObj            => 9;
  81. use constant frmPopupObj            => 10;
  82. use constant frmGraffitiStateObj    => 11;
  83. use constant frmGadgetObj            => 12;
  84. use constant frmScrollBarObj        => 13;
  85.  
  86. use constant hostSelectorGetHostVersion            => 0x0100;
  87. use constant hostSelectorGetHostID                => 0x0101;
  88. use constant hostSelectorGetHostPlatform        => 0x0102;
  89. use constant hostSelectorIsSelectorImplemented    => 0x0103;
  90. use constant hostSelectorGestalt                => 0x0104;
  91. use constant hostSelectorIsCallingTrap            => 0x0105;
  92.  
  93. use constant hostSelectorGremlinIsRunning        => 0x0400;
  94. use constant hostSelectorGremlinNumber            => 0x0401;
  95. use constant hostSelectorGremlinCounter            => 0x0402;
  96. use constant hostSelectorGremlinLimit            => 0x0403;
  97. use constant hostSelectorGremlinNew                => 0x0404;
  98.  
  99. use constant hostSelectorGetPreference            => 0x0600;
  100. use constant hostSelectorSetPreference            => 0x0601;
  101.  
  102. use constant hostSelectorLogFile                => 0x0700;
  103. use constant hostSelectorSetLogFileSize            => 0x0701;
  104.  
  105. use constant hostSelectorSessionCreate            => 0x0800;
  106. use constant hostSelectorSessionOpen            => 0x0801;
  107. use constant hostSelectorSessionClose            => 0x0802;
  108. use constant hostSelectorSessionQuit            => 0x0803;
  109. use constant hostSelectorSignalSend                => 0x0804;
  110. use constant hostSelectorSignalWait                => 0x0805;
  111. use constant hostSelectorSignalResume            => 0x0806;
  112.  
  113. use constant hwrDispType            => 0;    # (4) Get 4-char code for controller/display combination.
  114. use constant hwrDispRev                => 1;    # (2) Get Hardware Revision
  115. use constant hwrDispVers            => 2;    # (2) Get Display driver HAL version.
  116. use constant hwrDispAllDepths        => 3;    # (2) Get All display depths in bitmap format.
  117. use constant hwrDispMaxDepth        => 4;    # (2) Get Maximum supported bit depth.
  118. use constant hwrDispBootDepth        => 5;    # (2) The preset boot depth of the device.
  119. use constant hwrDispMaxGrays        => 6;    # (2) Get Maximum number of grays supported by HW.
  120. use constant hwrDispHorizontal        => 7;    # (2) Get Maximum hortizontal pixels supported by Display.
  121. use constant hwrDispVertical        => 8;    # (2) Get Maximum vertical pixels supported by Display.
  122. use constant hwrDispVRAMBaseAddr    => 9;    # (4) Get Base address of video memory if any (if 0, no VRAM)
  123. use constant hwrDispVRAMSize        => 10;    # (4) Get Size of VRAM (if 0, no VRAM)
  124. use constant hwrDispColor            => 11;    # (2) Get True if controller AND display supprt color.
  125. use constant hwrDispName            => 12;    #(32) Get 32 character string for controller and Hardware.
  126.     
  127. use constant hwrDispBaseAddr        => 13;    # (4) Get/Set Base Address for current screen memory (somewhere in VRAM or main RAM)
  128. use constant hwrDispDepth            => 14;    # (2) Get/Set Depth of display
  129. use constant hwrDispWidth            => 15;    # (2) Get/Set current display width
  130. use constant hwrDispHeight            => 16;    # (2) Get/Set current display height
  131. use constant hwrDispRowBytes        => 17;    # (2) Get/Set bytes in a row of display (changed when depth or width change)
  132. use constant hwrDispBacklight        => 18;    # (1) Get/Set Backlight status: 0 = off, 1 = on (returns 0 on Austin)
  133. use constant hwrDispBrightness        => 19;    # (1) Get/Set Brightness level: 0(min/off)...255(max)
  134. use constant hwrDispContrast        => 20;    # (1) Get/Set Contrast Level: 0(min)...255(max)
  135. use constant hwrDispDbgIndicator    => 21;    # (2) Turn Debug Indicator on/off
  136. use constant hwrDispEndAddr            => 22;    # (4) Get last byte of screen memory
  137. use constant hwrDispBufferMask        => 23;    # (4) Mask for determining required display address alignment
  138. use constant hwrDispResolutionX        => 24;    # (?) Screen resolution
  139. use constant hwrDispResolutionY        => 25;    # (?) Screen resolution
  140. use constant hwrDispMemAccessOK        => 26;    # (1) true if controller can be accessed when bus clock disabled
  141.  
  142.  
  143. ########################################################################
  144. #
  145. #    FUNCTION:        CtlGetLabel
  146. #
  147. #    DESCRIPTION:    Return a string pointer to the control's text label.
  148. #
  149. #    PARAMETERS:        Memory address on the remote device of the control
  150. #                    object.  Usually the result of something like
  151. #                    FrmGetObjectPtr on a control object.
  152. #
  153. #    RETURNED:        A list containing the memory address on the remote
  154. #                    device of the label, and the label string itself.
  155. #
  156. ########################################################################
  157.  
  158. sub CtlGetLabel
  159. {
  160.     # const Char* CtlGetLabel (const ControlType * ctlP)
  161.  
  162.     my ($return, $format) = ("string", "rptr");
  163.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapCtlGetLabel, $format, @_);
  164.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  165. }
  166.  
  167.  
  168. ########################################################################
  169. #
  170. #    FUNCTION:        DmNumDatabases
  171. #
  172. #    DESCRIPTION:    Returns the number of databases on a card
  173. #
  174. #    PARAMETERS:        card number
  175. #
  176. #    RETURNS:        Number of databases found
  177. #
  178. ########################################################################
  179.  
  180. sub DmNumDatabases
  181. {
  182.     # UInt DmNumDatabases (UInt cardNo)
  183.  
  184.     my ($return, $format) = ("int16", "int16");
  185.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapDmNumDatabases, $format, @_);
  186.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  187. }
  188.  
  189.  
  190. ########################################################################
  191. #
  192. #    FUNCTION:        DmDatabaseInfo
  193. #
  194. #    DESCRIPTION:    Retrieves database information
  195. #
  196. #    PARAMETERS:        Card number, database LocalID
  197. #
  198. #    RETURNS:        Result code from function, as well as the components
  199. #                    of a hash.  To get the result, assign the result
  200. #                    of this function to ($err, %results).  You can
  201. #                    then extract individual values from %results using
  202. #                    hash operators and the following keys: name
  203. #                    attributes, version, crDate, modDate, bckUpDate,
  204. #                    modNum, appInfoID, sortInfoID, type, and creator.
  205. #                    Example: $name = $results{name}.
  206. #
  207. ########################################################################
  208.  
  209. sub DmDatabaseInfo
  210. {
  211.     # Err DmDatabaseInfo (UInt cardNo, LocalID    dbID, const CharPtr nameP,
  212.     #                UIntPtr attributesP, UIntPtr versionP, ULongPtr crDateP,
  213.     #                ULongPtr modDateP, ULongPtr bckUpDateP,
  214.     #                ULongPtr modNumP, LocalID* appInfoIDP,
  215.     #                LocalID* sortInfoIDP, ULongPtr typeP,
  216.     #                ULongPtr creatorP)
  217.  
  218.     my ($cardNo, $dbID) = @_;
  219.  
  220.     my ($format) = "int16 LocalID string32 int16* int16* int32* int32* " .
  221.                     "int32* int32* LocalID* LocalID* int32* int32*";
  222.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapDmDatabaseInfo, $format,
  223.                         $cardNo, $dbID, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  224.  
  225.     ($D0,    name        => $params[2],
  226.             attributes    => $params[3],
  227.             version        => $params[4],
  228.             crDate        => $params[5],
  229.             modDate        => $params[6],
  230.             bckUpDate    => $params[7],
  231.             modNum        => $params[8],
  232.             appInfoID    => $params[9],
  233.             sortInfoID    => $params[10],
  234.             type        => $params[11],
  235.             creator        => $params[12]);
  236. }
  237.  
  238.  
  239. ########################################################################
  240. #
  241. #    FUNCTION:        DmFindDatabase
  242. #
  243. #    DESCRIPTION:    Searches for a database by name
  244. #
  245. #    PARAMETERS:        card number, database name
  246. #
  247. #    RETURNS:        LocalID of database header
  248. #
  249. ########################################################################
  250.  
  251. sub DmFindDatabase
  252. {
  253.     # LocalID DmFindDatabase (UInt cardNo, const CharPtr nameP)
  254.  
  255.     my ($return, $format) = ("LocalID", "int16 string");
  256.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapDmFindDatabase, $format, @_);
  257.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  258. }
  259.  
  260.  
  261. ########################################################################
  262. #
  263. #    FUNCTION:        EvtEnqueuePenPoint
  264. #
  265. #    DESCRIPTION:    Called by the digitizer interrupt routine to enqueue
  266. #                    a pen coordinate into the pen queue.
  267. #
  268. #    PARAMETERS:        x and y coordinates, subtracted from 256.
  269. #                    Example: EvtEnqueuePoint (256 - 100, 256 - 80)
  270. #                    Pass in (-1, -1) to enqueue a Pen Up.
  271. #
  272. #    RETURNS:        size of queue in bytes
  273. #
  274. ########################################################################
  275.  
  276. sub EvtEnqueuePenPoint
  277. {
  278.     # Err EvtEnqueuePenPoint (PointType* ptP)
  279.  
  280.     my ($return, $format) = ("Err", "point");
  281.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapEvtEnqueuePenPoint, $format, @_);
  282.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  283. }
  284.  
  285. ########################################################################
  286. #
  287. #    FUNCTION:        EvtEnqueueKey
  288. #
  289. #    DESCRIPTION:    Called by the digitizer interrupt routine to enqueue
  290. #                    a key into the key queue.
  291. #
  292. #    PARAMETERS:        WChar ascii, UInt16 keycode, UInt16 modifiers
  293. #
  294. #    RETURNS:        size of queue in bytes
  295. #
  296. ########################################################################
  297.  
  298. sub EvtEnqueueKey
  299. {
  300.     # Err EvtEnqueueKey (WChar ascii, UInt16 keycode, UInt16 modifiers)
  301.  
  302.     my ($return, $format) = ("Err", "int16 int16 int16");
  303.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapEvtEnqueueKey, $format, @_);
  304.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  305. }
  306.  
  307.  
  308. ########################################################################
  309. #
  310. #    FUNCTION:        FrmGetActiveForm
  311. #
  312. #    DESCRIPTION:    This routine returns the currently active form.
  313. #
  314. #    PARAMETERS:        nothing
  315. #
  316. #    RETURNED:        Memory address on the remote device of the form.
  317. #
  318. ########################################################################
  319.  
  320. sub FrmGetActiveForm
  321. {
  322.     # FormPtr FrmGetActiveForm (void)
  323.  
  324.     my ($return, $format) = ("rptr", "");
  325.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapFrmGetActiveForm, $format, @_);
  326.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  327. }
  328.  
  329.  
  330. ########################################################################
  331. #
  332. #    FUNCTION:        FrmGetLabel
  333. #
  334. #    DESCRIPTION:    This routine return the text of the specified label object
  335. #                    in the specified form.
  336. #
  337. #    PARAMETERS:        formP        - memory block that contains the form.
  338. #                    labelID        - id of the label object.
  339. #
  340. #    RETURNED:        A list containing the memory address on the remote
  341. #                    device of the label, and the label string itself.
  342. #
  343. ########################################################################
  344.  
  345. sub FrmGetLabel
  346. {
  347.     # CharPtr FrmGetLabel (const FormPtr frm, const Word lableID)
  348.  
  349.     my ($return, $format) = ("string", "rptr int16");
  350.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapFrmGetLabel, $format, @_);
  351.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  352. }
  353.  
  354.  
  355. ########################################################################
  356. #
  357. #    FUNCTION:        FrmGetNumberOfObjects
  358. #
  359. #    DESCRIPTION:    This routine returns the number of objects in a form.
  360. #
  361. #    PARAMETERS:        formP        memory block that contains the form.
  362. #
  363. #    RETURNED:        number of object in the form specified
  364. #
  365. ########################################################################
  366.  
  367. sub FrmGetNumberOfObjects
  368. {
  369.     # Word FrmGetNumberOfObjects (const FormPtr frm)
  370.  
  371.     my ($return, $format) = ("int16", "rptr");
  372.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapFrmGetNumberOfObjects, $format, @_);
  373.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  374. }
  375.  
  376.  
  377. ########################################################################
  378. #
  379. #    FUNCTION:        FrmGetObjectBounds
  380. #
  381. #    DESCRIPTION:    This routine returns the bounds of the specified form object
  382. #
  383. #    PARAMETERS:        formP        memory block that contains the form.
  384. #                    objIndex    index of the object
  385. #
  386. #    RETURNS:        The components of a hash.  To get the result, assign
  387. #                    the result of this function to %results.  You can
  388. #                    then extract individual values from %results using
  389. #                    hash operators and the following keys: top, left
  390. #                    bottom, right, width, height.
  391. #                    Example: $top = $results{top}.
  392. #
  393. ########################################################################
  394.  
  395. sub FrmGetObjectBounds
  396. {
  397.     # void FrmGetObjectBounds (const FormPtr frm, const Word pObjIndex, const RectanglePtr r)
  398.  
  399.     my ($form, $obj_index) = @_;
  400.  
  401.     my ($return, $format) = ("", "rptr int16 rect");
  402.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapFrmGetObjectBounds, $format,
  403.                                             $form, $obj_index, {});
  404.  
  405.     my ($foo) = $params[2];
  406.     %$foo;
  407. }
  408.  
  409.  
  410. ########################################################################
  411. #
  412. #    FUNCTION:        FrmGetObjectId
  413. #
  414. #    DESCRIPTION:    This routine returns the id of the object specified.  
  415. #                    An id is a value specified by the application developer 
  416. #                    that uniquely identifies an object.
  417. #
  418. #    PARAMETERS:        formP        memory block that contains the form.
  419. #                    objIndex    item number of the object
  420. #
  421. #    RETURNED:        Object ID.
  422. #
  423. ########################################################################
  424.  
  425. sub FrmGetObjectId
  426. {
  427.     # UInt16 FrmGetObjectId (const FormType * formP, UInt16 objIndex)
  428.  
  429.     my ($return, $format) = ("int16", "rptr int16");
  430.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapFrmGetObjectId, $format, @_);
  431.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  432. }
  433.  
  434.  
  435. ########################################################################
  436. #
  437. #    FUNCTION:        FrmGetObjectIndex
  438. #
  439. #    DESCRIPTION:    This routine returns the item number of an object, the
  440. #                    item number is the position of the object in the objects
  441. #                    list.
  442. #
  443. #    PARAMETERS:        formP        memory block that contains the form.
  444. #                    objId        id of an object in the form.
  445. #
  446. #    RETURNED:        item number of an object (the first item number is 0).
  447. #
  448. ########################################################################
  449.  
  450. sub FrmGetObjectIndex
  451. {
  452.     # UInt16 FrmGetObjectIndex (const FormType * formP, UInt16 objId)
  453.  
  454.     my ($return, $format) = ("int16", "rptr int16");
  455.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapFrmGetObjectIndex, $format, @_);
  456.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  457. }
  458.  
  459.  
  460. ########################################################################
  461. #
  462. #    FUNCTION:        FrmGetObjectPtr
  463. #
  464. #    DESCRIPTION:    This routine returns a pointer to the data structure of an 
  465. #                    object in a form.
  466. #
  467. #    PARAMETERS:        formP        memory block that contains the form.
  468. #                    objIndex    item number of the object
  469. #
  470. #    RETURNED:        Memory address on the remote device of the object.
  471. #                    The contents of the object depend on the object type.
  472. #
  473. ########################################################################
  474.  
  475. sub FrmGetObjectPtr
  476. {
  477.     # VoidPtr FrmGetObjectPtr (const FormPtr frm, const Word objIndex)
  478.  
  479.     my ($return, $format) = ("rptr", "rptr int16");
  480.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapFrmGetObjectPtr, $format, @_);
  481.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  482. }
  483.  
  484.  
  485. ########################################################################
  486. #
  487. #    FUNCTION:        FrmGetObjectType
  488. #
  489. #    DESCRIPTION:    This routine returns the type of an object.
  490. #
  491. #    PARAMETERS:        formP        memory block that contains the form.
  492. #                    objIndex    item number of the object
  493. #
  494. #    RETURNED:        FormObjectType of the item specified
  495. #
  496. ########################################################################
  497.  
  498. sub FrmGetObjectType
  499. {
  500.     # FormObjectKind FrmGetObjectType (const FormPtr frm, const Word objIndex)
  501.  
  502.     my ($return, $format) = ("int16", "rptr int16");
  503.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapFrmGetObjectType, $format, @_);
  504.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  505. }
  506.  
  507. ########################################################################
  508. #
  509. #    FUNCTION:        FrmGetTitle
  510. #
  511. #    DESCRIPTION:    This routine returns a pointer to the title string of a 
  512. #                    form.
  513. #
  514. #    PARAMETERS:        formP      - memory block that contains the form.
  515. #
  516. #    RETURNED:        A list containing the memory address on the remote
  517. #                    device of the title, and the title string itself.
  518. #
  519. ########################################################################
  520.  
  521. sub FrmGetTitle
  522. {
  523.     # const Char * FrmGetTitle (const FormType * formP)
  524.  
  525.     my ($return, $format) = ("string", "rptr");
  526.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapFrmGetTitle, $format, @_);
  527.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  528. }
  529.  
  530.  
  531. ########################################################################
  532. #
  533. #    FUNCTION:        FtrGet
  534. #
  535. #    DESCRIPTION:    Get a PalmOS feature setting
  536. #
  537. #    PARAMETERS:        creator - creator id
  538. #                    featureNum - number of feature requested
  539. #
  540. #    RETURNS:        Result code and value of feature
  541. #
  542. ########################################################################
  543.  
  544. sub FtrGet
  545. {
  546.     # Err FtrGet(UInt32 creator, UInt16 featureNum, UInt32 *valueP)
  547.  
  548.     my ($creator, $featureNum) = @_;
  549.  
  550.     my ($return, $format) = ("Err", "int32 int16 int32*");
  551.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapFtrGet, $format, $creator, $featureNum, 0);
  552.     ($D0, $params[2]);
  553. }
  554.  
  555.  
  556. ########################################################################
  557. #
  558. #    FUNCTION:        HostGetHostVersion
  559. #
  560. #    DESCRIPTION:    Get the version of the host (Palm OS Emulator).
  561. #
  562. #    PARAMETERS:        None
  563. #
  564. #    RETURNS:        Version number of Poser in Palm OS version format.
  565. #
  566. ########################################################################
  567.  
  568. sub HostGetHostVersion
  569. {
  570.     # long HostGetHostVersion(void)
  571.  
  572.     my ($return, $format) = ("int32", "int16");
  573.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapHostControl, $format,
  574.                         hostSelectorGetHostVersion, @_);
  575.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  576. }
  577.  
  578.  
  579. ########################################################################
  580. #
  581. #    FUNCTION:        HostGremlinNew
  582. #
  583. #    DESCRIPTION:    Start a new Gremlin Horde.
  584. #
  585. #    PARAMETERS:        Starting Gremlin number.
  586. #                    Ending Gremlin number.
  587. #                    Frequency (in terms of Gremlin events) at which
  588. #                        states are automatically saved.
  589. #                    Switching depth (number of events generated before
  590. #                        switching to a different Gremlin).
  591. #                    Max depth (maximum number of events generated
  592. #                        for each Gremlin).
  593. #                    List of application names on which to run Gremlins.
  594. #
  595. #    RETURNS:        Error code.
  596. #
  597. ########################################################################
  598.  
  599. sub HostGremlinNew
  600. {
  601.     # HostErr HostGremlinNew(const HostGremlinInfo*)
  602.  
  603.     ($start, $stop, $save_freq, $switch_depth, $max_depth, @apps) = @_;
  604.  
  605.     my ($app_string) = join (",", @apps);
  606.  
  607.     my ($struct) = pack("NNNNN", $start, $stop, $save_freq, $switch_depth, $max_depth) . $app_string;
  608.  
  609.     my ($return, $format) = ("HostErr", "int16 block");
  610.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapHostControl, $format,
  611.                         hostSelectorGremlinNew, $struct);
  612.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  613. }
  614.  
  615.  
  616. ########################################################################
  617. #
  618. #    FUNCTION:        HostSetLogFileSize
  619. #
  620. #    DESCRIPTION:    Create a new session.
  621. #
  622. #    PARAMETERS:        Name of device to emulate.  Choices are: "Pilot",
  623. #                        "PalmPilot", "Palm III", "Palm IIIx",
  624. #                        "Palm V", "Palm VII".
  625. #                    RAM size (in K) to emulate.
  626. #                    Path to ROM to use.
  627. #
  628. #    RETURNS:        Error code.
  629. #
  630. ########################################################################
  631.  
  632. sub HostSetLogFileSize
  633. {
  634.     # void HostSetLogFileSize(long)
  635.  
  636.     my ($return, $format) = ("HostErr", "int32");
  637.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapHostControl, $format,
  638.                         hostSelectorSetLogFileSize, @_);
  639.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  640. }
  641.  
  642.  
  643. ########################################################################
  644. #
  645. #    FUNCTION:        HostSessionCreate
  646. #
  647. #    DESCRIPTION:    Create a new session.
  648. #
  649. #    PARAMETERS:        Name of device to emulate.  Choices are: "Pilot",
  650. #                        "PalmPilot", "Palm III", "Palm IIIx",
  651. #                        "Palm V", "Palm VII".
  652. #                    RAM size (in K) to emulate.
  653. #                    Path to ROM to use.
  654. #
  655. #    RETURNS:        Error code.
  656. #
  657. ########################################################################
  658.  
  659. sub HostSessionCreate
  660. {
  661.     # HostErr HostSessionCreate(const char* device, long ramSize, const char* romPath)
  662.  
  663.     my ($return, $format) = ("HostErr", "int16 string int32 string");
  664.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapHostControl, $format,
  665.                         hostSelectorSessionCreate, @_);
  666.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  667. }
  668.  
  669.  
  670. ########################################################################
  671. #
  672. #    FUNCTION:        HostSessionOpen
  673. #
  674. #    DESCRIPTION:    Open a previously create session file.
  675. #
  676. #    PARAMETERS:        Path to session file to open.
  677. #
  678. #    RETURNS:        Error code.
  679. #
  680. ########################################################################
  681.  
  682. sub HostSessionOpen
  683. {
  684.     # HostErr HostSessionOpen(const char* psfFileName)
  685.  
  686.     my ($return, $format) = ("HostErr", "int16 string");
  687.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapHostControl, $format,
  688.                         hostSelectorSessionOpen, @_);
  689.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  690. }
  691.  
  692.  
  693. ########################################################################
  694. #
  695. #    FUNCTION:        HostSessionClose
  696. #
  697. #    DESCRIPTION:    Close the current session, optionally saving it.
  698. #
  699. #    PARAMETERS:        Name of session file to create. Can be null.
  700. #
  701. #    RETURNS:        Error code.
  702. #
  703. ########################################################################
  704.  
  705. sub HostSessionClose
  706. {
  707.     # HostErr HostSessionClose(const char* saveFileName)
  708.  
  709.     my ($return, $format) = ("HostErr", "int16 string");
  710.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapHostControl, $format,
  711.                         hostSelectorSessionClose, @_);
  712.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  713. }
  714.  
  715.  
  716. ########################################################################
  717. #
  718. #    FUNCTION:        HostSessionQuit
  719. #
  720. #    DESCRIPTION:    Ask Palm OS Emulator to quit.
  721. #
  722. #    PARAMETERS:        None
  723. #
  724. #    RETURNS:        Error code.
  725. #
  726. ########################################################################
  727.  
  728. sub HostSessionQuit
  729. {
  730.     # HostErr HostSessionQuit(void)
  731.  
  732.     my ($return, $format) = ("HostErr", "int16");
  733.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapHostControl, $format,
  734.                         hostSelectorSessionQuit, @_);
  735.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  736. }
  737.  
  738.  
  739. ########################################################################
  740. #
  741. #    FUNCTION:        HostSignalWait
  742. #
  743. #    DESCRIPTION:    Wait for a signal from the Palm OS Emulator.
  744. #
  745. #    PARAMETERS:        timeout (in milliseconds)
  746. #
  747. #    RETURNS:        List containing the error code and the numeric
  748. #                    signal value returned from the Emulator.
  749. #
  750. ########################################################################
  751.  
  752. sub HostSignalWait
  753. {
  754.     # HostErr HostSignalWait(long timeout, HostSignal* signalNumber)
  755.  
  756.     my ($return, $format) = ("HostErr", "int16 int32 int32*");
  757.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapHostControl, $format,
  758.                         hostSelectorSignalWait, $_[0], 0);
  759.  
  760.     ($D0, $params[2]);    # 0 = selector, 1 = timeout, 2 = signal number
  761. }
  762.  
  763.  
  764. ########################################################################
  765. #
  766. #    FUNCTION:        HostSignalResume
  767. #
  768. #    DESCRIPTION:    Tell the Emulator to resume after it has sent us
  769. #                    a signal.
  770. #
  771. #    PARAMETERS:        None
  772. #
  773. #    RETURNS:        Error code.
  774. #
  775. ########################################################################
  776.  
  777. sub HostSignalResume
  778. {
  779.     # HostErr HostSignalResume(void)
  780.  
  781.     my ($return, $format) = ("HostErr", "int16");
  782.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapHostControl, $format,
  783.                         hostSelectorSignalResume, @_);
  784.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  785. }
  786.  
  787.  
  788. ########################################################################
  789. #
  790. #    FUNCTION:        HwrDisplayAttributes
  791. #
  792. #    DESCRIPTION:    Get or set Info about the Hwr display and controller
  793. #
  794. #    PARAMETERS:        set - true to set, false to get.  Ignored for read-only attributes
  795. #                    attr - HwrDisplayAttrType
  796. #                    dataP - data to get or set.  Must be non-NULL, as read-only
  797. #                        attributes are always read, regardless of 'set' param.
  798. #
  799. #    RETURNS:        
  800. #
  801. ########################################################################
  802.  
  803. sub HwrDisplayAttributes
  804. {
  805.     # Err HwrDisplayAttributes(Boolean set, HwrDisplayAttrType attr, void* dataP)
  806.  
  807.     my ($set, $attr, $data) = @_;
  808.  
  809.     my ($return, $format) = ("Err", "int8 int8 block");
  810.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapHwrDisplayAttributes, $format, $set, $attr, $data);
  811.     ($D0, $params[2]);
  812. }
  813.  
  814.  
  815. ########################################################################
  816. #
  817. #    FUNCTION:        MemChunkFree
  818. #
  819. #    DESCRIPTION:    Disposes of a chunk
  820. #
  821. #    PARAMETERS:        Pointer to chunk
  822. #
  823. #    RETURNS:        0 if no error
  824. #
  825. ########################################################################
  826.  
  827. sub MemChunkFree
  828. {
  829.     my ($return, $format) = ("Err", "rptr");
  830.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapMemChunkFree, $format, @_);
  831.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  832. }
  833.  
  834.  
  835. ########################################################################
  836. #
  837. #    FUNCTION:        MemPtrFree
  838. #
  839. #    DESCRIPTION:    Disposes of a chunk
  840. #
  841. #    PARAMETERS:        Pointer to chunk
  842. #
  843. #    RETURNS:        0 if no error
  844. #
  845. ########################################################################
  846.  
  847. sub MemPtrFree
  848. {
  849.     MemChunkFree (@_);
  850. }
  851.  
  852.  
  853. ########################################################################
  854. #
  855. #    FUNCTION:        MemPtrNew
  856. #
  857. #    DESCRIPTION:    Allocates a non-movable chunk in the dynamic heap
  858. #
  859. #    PARAMETERS:        requested size of chunk
  860. #
  861. #    RETURNS:        Ptr to chunk, or 0 if error
  862. #
  863. ########################################################################
  864.  
  865. sub MemPtrNew
  866. {
  867.     my ($return, $format) = ("rptr", "int32");
  868.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapMemPtrNew, $format, @_);
  869.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  870. }
  871.  
  872.  
  873. ########################################################################
  874. #
  875. #    FUNCTION:        MemPtrSetOwner
  876. #
  877. #    DESCRIPTION:    Sets the owner ID of a chunk
  878. #
  879. #    PARAMETERS:        chunk data pointer
  880. #
  881. #    RETURNS:        0 if no error
  882. #
  883. ########################################################################
  884.  
  885. sub MemPtrSetOwner
  886. {
  887.     #    Err  MemPtrSetOwner (void* p, UInt16 owner)
  888.  
  889.     my ($return, $format) = ("Err", "rptr int16");
  890.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapMemPtrSetOwner, $format, @_);
  891.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  892. }
  893.  
  894.  
  895. ########################################################################
  896. #
  897. #    FUNCTION:        SysUIAppSwitch
  898. #
  899. #    DESCRIPTION:    Tries to make the current UI application quit and
  900. #                    then launches the given UI application by card
  901. #                    number and database ID.
  902. #
  903. #    PARAMETERS:        cardNo, dbID, launchCmd, cmdPBP
  904. #
  905. #                    Note that in order to utilize the cmdPBP, you need
  906. #                    to first create a buffer on the remote side with
  907. #                    MemPtrNew and fill in its contents with
  908. #                    EmRPC::WriteBlock.  If you want to pass NULL for
  909. #                    cmdPBP, specify zero for the last parameter.
  910. #
  911. #    RETURNS:        errNone if no err
  912. #
  913. ########################################################################
  914.  
  915. sub SysUIAppSwitch
  916. {
  917.     # Err SysUIAppSwitch(UInt16 cardNo, LocalID dbID, UInt16 cmd, MemPtr cmdPBP)
  918.  
  919.     my ($return, $format) = ("Err", "int16 LocalID int16 rptr");
  920.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapSysUIAppSwitch, $format, @_);
  921.     EmRPC::ReturnValue ($return, $D0, $A0, @params);
  922. }
  923.  
  924.  
  925. ########################################################################
  926. #
  927. #    FUNCTION:        WinDisplayToWindowPt
  928. #
  929. #    DESCRIPTION:    This routine converts a display-relative coordinate to
  930. #                    a window-relative coordinate.  The coordinate returned is 
  931. #                    relative to the draw window.
  932. #
  933. #    PARAMETERS:        xP    <->    x coordinate to convert
  934. #                    yP    <->    y coordinate to convert
  935. #
  936. #    RETURNED:        nothing
  937. #
  938. ########################################################################
  939.  
  940. sub WinDisplayToWindowPt
  941. {
  942.     # void WinDisplayToWindowPt (Coord * xP, Coord * yP)
  943.  
  944.     my ($return, $format) = ("void", "Coord* Coord*");
  945.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapWinDisplayToWindowPt, $format, @_);
  946.     ($params[0], $params[1]);
  947. }
  948.  
  949.  
  950. ########################################################################
  951. #
  952. #    FUNCTION:        WinWindowToDisplayPt
  953. #
  954. #    DESCRIPTION:    This routine converts a window-relative coordinate to
  955. #                    a display-relative coordinate.  The coordinate passed is 
  956. #                    assumed to be relative to the draw window.
  957. #
  958. #    PARAMETERS:        xP    <->    x coordinate to convert
  959. #                    yP    <->    y coordinate to convert
  960. #
  961. #    RETURNED:        nothing
  962. #
  963. ########################################################################
  964.  
  965. sub WinWindowToDisplayPt
  966. {
  967.     # void WinWindowToDisplayPt (Coord * xP, Coord * yP)
  968.  
  969.     my ($return, $format) = ("void", "Coord* Coord*");
  970.     my ($D0, $A0, @params) = EmRPC::DoRPC (sysTrapWinWindowToDisplayPt, $format, @_);
  971.     ($params[0], $params[1]);
  972. }
  973.  
  974. 1;
  975.